#!/bin/sh
################################################################################
# font
################################################################################
. /etc/rc.d/functions

start() {
    local font

    /bin/touch /var/lib/init/font.inprogress

    /usr/bin/logger -s -t minimyth -p "local0.info" "[init.d/font] Starting..."

    if [ -n "${MM_FONT_FILE_TTF_DELETE}" ] || [ -n "${MM_FONT_FILE_TTF_ADD}" ] ; then
        /bin/mkdir -p /usr/share/fonts/X11/TTF
        /bin/mkdir -p /usr/share/mythtv
        if [ -n "${MM_FONT_FILE_TTF_DELETE}" ] ; then
            for font in ${MM_FONT_FILE_TTF_DELETE} ; do
                /bin/rm -f /usr/share/fonts/X11/TTF/${font}
                /bin/rm -f /usr/share/mythtv/${font}
            done
        fi
        if [ -n "${MM_FONT_FILE_TTF_ADD}" ] ; then
            for font in ${MM_FONT_FILE_TTF_ADD} ; do
                /bin/rm -f /usr/share/mythtv/${font}
                if [ -e /usr/share/fonts/X11/TTF/${font} ] ; then
                    /bin/ln -sf /usr/share/fonts/X11/TTF/${font} /usr/share/mythtv/${font}
                fi
            done
        fi
        cd /usr/share/fonts/X11/TTF
        /usr/bin/mkfontscale
        /usr/bin/mkfontdir
    fi

    /usr/bin/logger -s -t minimyth -p "local0.info" "[init.d/font] Started with return code=0..."

    /bin/rm -f /var/lib/init/font.inprogress

    return 0
}

stop() {
    return 0
}

case $1 in
    start) start ;;
    stop)  stop  ;;
esac

exit 0
